package com.dailyblue.project.estate.letter.controller;

import com.dailyblue.project.estate.commons.bean.Letter;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.letter.service.LetterService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/letter")
public class LetterController {
    @Resource
    private LetterService letterService;

    @PostMapping
    public JsonResult save(Letter letter) {
        return letterService.addLetter(letter);
    }

    @GetMapping("/findOne/{id}")
    public JsonResult findOneLetter(@PathVariable("id") String letterId) {
        return letterService.findOneLetter(letterId);
    }

    @GetMapping
    public JsonResult findAllLetters() {
        return letterService.findAllLetters();
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult deleteLetter(@PathVariable("id")String letterId) {
        return letterService.deleteLetter(letterId);
    }

    @PostMapping("/update")
    public JsonResult updateLetter(@RequestBody Letter letter) {
        return letterService.updateLetter(letter);
    }
}
